//
//  FreeUseView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/10/17.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "FreeUseView.h"

@implementation FreeUseView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        SDCycleScrollView *cycleScrollView;
        
        cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero imageNamesGroup:@[[UIImage imageNamed:@"img_screen_one"],[UIImage imageNamed:@"img_screen_two"]]];
        
//        cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
//        cycleScrollView.infiniteLoop = NO;
//        cycleScrollView.autoScroll = NO;
//        cycleScrollView.currentPageDotColor = ButtonBackGroundColor;
//        cycleScrollView.pageDotColor = CSBlackColor;
        cycleScrollView.showPageControl = NO;
        [self addSubview:cycleScrollView];
        self.cycleScrollView = cycleScrollView;
        
        UIButton *freeUseBtn = [[UIButton alloc] init];
        freeUseBtn.backgroundColor = ButtonBackGroundColor;
        freeUseBtn.layer.cornerRadius = 2;
        freeUseBtn.layer.masksToBounds = YES;
        freeUseBtn.titleLabel.font = MidBigFont;
        [freeUseBtn setTitleColor:CSColorFromRGB(0x0a0a0a) forState:UIControlStateNormal];
        [freeUseBtn setTitle:@"免费使用" forState:UIControlStateNormal];

        [self addSubview:freeUseBtn];
        self.freeUseBtn = freeUseBtn;
        
        UIButton *freeUseBtn1 = [[UIButton alloc] init];
        freeUseBtn1.backgroundColor = ButtonBackGroundColor;
        freeUseBtn1.layer.cornerRadius = 2;
        freeUseBtn1.layer.masksToBounds = YES;
        freeUseBtn1.titleLabel.font = MidBigFont;
        freeUseBtn1.hidden = YES;
        [freeUseBtn1 setTitleColor:CSColorFromRGB(0x0a0a0a) forState:UIControlStateNormal];
        [freeUseBtn1 setTitle:@"免费使用" forState:UIControlStateNormal];
        [self addSubview:freeUseBtn1];
        self.freeUseBtn1 = freeUseBtn1;
        
        UIButton *loginBtn = [[UIButton alloc] init];
        [loginBtn setTitleColor:CSColorFromRGB(0x0a0a0a) forState:UIControlStateNormal];
        [loginBtn setTitle:@"立即登录" forState:UIControlStateNormal];
        
        loginBtn.titleLabel.font = MidFont;
        loginBtn.layer.cornerRadius = 4;
        loginBtn.layer.masksToBounds = YES;
        loginBtn.layer.borderColor = CSColorFromRGB(0x000000).CGColor;
        loginBtn.layer.borderWidth = 1;
        [self addSubview:loginBtn];
        self.loginBtn = loginBtn;
        
        [cycleScrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(self);
            
            make.left.width.mas_equalTo(self);
            
            make.bottom.mas_equalTo(self).offset(-120);
        }];
        
        [freeUseBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

            make.top.mas_equalTo(cycleScrollView.mas_bottom).offset(30);

            make.left.mas_equalTo(self).offset(20);

            make.right.mas_equalTo(loginBtn.mas_left).offset(-15);

            make.height.mas_equalTo(50);
        }];

        [freeUseBtn1 mas_remakeConstraints:^(MASConstraintMaker *make) {

            make.top.mas_equalTo(cycleScrollView.mas_bottom).offset(30);

            make.centerX.mas_equalTo(self);

            make.height.mas_equalTo(50);

            make.left.mas_equalTo(self).offset(40);

            make.right.mas_equalTo(self).offset(-40);
        }];

        [loginBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

            make.top.mas_equalTo(freeUseBtn);

            make.right.mas_equalTo(self).offset(-20);

            make.width.height.mas_equalTo(freeUseBtn);
        }];
    }
    
    return self;
}

@end
